#include <bits/stdc++.h>
using namespace std;
char buf[(int) 5e7], *fs = buf;
inline int gn() { 
    int k = 0;
    char c = *fs++;
    for (; !isdigit(c); c = *fs++);
    for (; isdigit(c); c = *fs++) k = k * 10 + c - '0';
    return k;
}
const int maxn = 2e5 + 3;
int a[maxn], n, m;
bool vis[maxn];
int main() { 
    freopen("position.in", "r", stdin);
    freopen("position.out", "w", stdout);
    fread(buf, 1, (int) 5e7, stdin);
    n = gn(), m = gn();
    for (int i = 1; i <= n; i++)
        a[i] = gn();
    for (int i = 1, t, l, r; i <= m; i++) { 
        t = gn(), l = gn(), r = gn();
        if (t == 1) { 
            a[l] += r;
        } else if (t == 2) { 
            a[l] -= r;
        } else if (t == 3) { 
            for (int i = l; i <= r; i++) 
                vis[i] = 0;
        } else if (t == 4) { 
            for (int i = l; i <= r; i++) 
                vis[i] = 1;
        }
        int ans = -1, dis = 0x7fffffff;
        for (int i = 1; i <= n; i++) { 
            if (vis[i]) continue;
            int tmp = 0;
            for (int j = 1; j <= n; j++)
                tmp += a[j] * abs(j - i);
            if (tmp < dis) { 
                dis = tmp;
                ans = i;
            }
        }
        cout << ans << '\n';
    }
}
